﻿#region File Header

/* File Name    : FacebookCommentManager.cs
 * Description  : Manage status messages on Facebook user wall
 * Log
 * Date             Author              Description
 * 19-Oct-2011      Robin Jome          Class is created
 */

#endregion

#region Namespaces

using FacebookAPI.Base;
using FacebookAPI.FacebookProperties;
using FacebookAPI.Objects;

#endregion

namespace FacebookAPI.Managers
{
    #region Class

    /// <summary>
    /// Manage status messages on Facebook user wall
    /// </summary>
    public class StatusMessageManager
    {
        #region Methods

        /// <summary>
        /// Creates a comment on a Facebook object
        /// </summary>
        /// <param name="objectId">The Id of the object on which status message should be posted</param>
        /// <param name="statusMessage">The Facebook status message object</param>
        /// <param name="accessToken">The Facebook access token</param>
        /// <returns>Returns the Id of the newly created Comment</returns>
        public string CreateStatusMessage(string objectId, StatusMessage statusMessage, string accessToken)
        {
            FacebookManager mgr = new FacebookManager();
            FacebookBaseObject response = mgr.SaveObject<FacebookBaseObject>(mgr.GetUrl(objectId, null, accessToken),statusMessage.GetPostData());
            return (response != null) ? response.Id : string.Empty;
        }

        /// <summary>
        /// Deletes a status message
        /// </summary>
        /// <param name="statusMessageId">The id of the status message</param>
        /// <param name="accessToken">The Facebook access token</param>
        /// <returns>Returns true if deleted</returns>
        public bool DeleteStatusMessage(string statusMessageId, string accessToken)
        {
            FacebookManager mgr = new FacebookManager();
            return mgr.DeleteObject<bool>(mgr.GetUrl(statusMessageId, null, accessToken));
        }

        /// <summary>
        /// Likes a status message
        /// </summary>
        /// <param name="statusMessageId">The Id of the Facebook status message</param>
        /// <param name="accessToken">The Facebook access token</param>
        /// <returns>Returns true if liked the comment</returns>
        public bool LikeTheStatus(string statusMessageId, string accessToken)
        {
            FacebookManager mgr = new FacebookManager();
            return mgr.SaveObject<bool>(mgr.GetUrl(statusMessageId, FacebookConnections.Likes, accessToken));
        }

        /// <summary>
        /// Un-likes a status message
        /// </summary>
        /// <param name="statusMessageId">The Id of the Facebook status message</param>
        /// <param name="accessToken">The Facebook access token</param>
        /// <returns>Returns true if unlike was successful</returns>
        public bool UnlikeTheStatus(string statusMessageId, string accessToken)
        {
            FacebookManager mgr = new FacebookManager();
            return mgr.DeleteObject<bool>(mgr.GetUrl(statusMessageId, FacebookConnections.Likes, accessToken));
        }

        #endregion

        #region Connections

        #endregion
    }

    #endregion
}
